import request from "@/utils/request";
import { stringify } from "qs";
import { toFormData } from '@/utils/utils';

export async function getZJFGoodsPage(params) {
	return request(`/blade-goods/zjfgoods/list/fuzzyQueryPageNew`, { method: "Post", loading: true, data: params });
}
// 获取门店（供应商）列表
export async function getZJFStorePage(params) {
	return request(`/blade-goods/zjfstore/list/fuzzyQueryPage?${stringify(params)}`, { method: "GET", loading: true });
}
// SKU匹配
export async function goodsSkuMatch(params) {
	return request(`/new-goods/goods/sku/match`, { method: "Post", loading: true, data: params });
}

// SPU匹配
export async function goodsSpuMatch(params) {
	return request(`/new-goods/goods/spu/match`, { method: "Post", loading: true, data: params });
}

export async function updateOrderMatchOp(params) {
	return request(`/new-goods/goods/sku/update-order-match`, {
		method: "post",
		data: params
	});
}

export async function getSupplierSpuList(params) {
	return request(`/blade-goods/zjfgoodscommon/list/fuzzyQueryGoodsCommonPage`, {
		method: "POST",
		loading: true,
		data: params
	});
}
/**
 * sn008 以图搜款
 * @param {*} params { industrialBeltFlag ⽤户产业带:0:家纺 1:服装 ,  url}
 * @returns
 */
export async function foreignOrdinarySearchByUrl(params) {
	return request(`/blade-goods/search/image/ordinarySearch`, {
		 method: "Post", 
		 body: toFormData(params),
		 loading: true,
	});
}

/**
 * sn008 以图搜款
 * @param {*} params { industrialBeltFlag ⽤户产业带:0:家纺 1:服装 ,  url}
 * @returns
 */
export async function foreignSeniorSearchByUrl(params) {
	return request(`/blade-goods/search/image/seniorSearch`, { 
		method: "Post", 
		body: toFormData(params),
		loading: true, 
	});
}

// 根据spuId查询sku匹配信息  id
export async function getMatchSkuListBySpuId(params) {
	return request(`/new-goods/goods/spu/get-sku-match-spu-id?${stringify(params)}`, { method: "GET", loading: true });
}

/**
 * 返回供应商sku列表信息
 * @param {*} params { goodsList，goodsCommonIdList }
 * @returns
 */
export async function getZjfGoodsSkuVOList(params) {
	return request(`/blade-goods/zjfgoods/getZjfGoodsSkuVOList`, {
		method: "POST",
		loading: true,
		data: params
	});
}

//订单商品精准匹配
export async function orderGoodsMatchOp(params) {
	return request(`/new-oms/order/goodsMatch`, {
		method: "POST",
		loading: true,
		data: params
	});
}

//订单商品供应商匹配
export async function supplierMatchOp(params) {
	return request(`/new-oms/order/supplierMatch`, {
		method: "post",
		data: params
	});
}

//更换匹配
export async function changeGoodsSkuMatch(params) {
	return request(`/new-goods/goods/sku/update-match`, {
		method: "Post",
		data: params,
		loading: true
	});
}
